package com.qf.service.impl;

import com.qf.dao.BookDao;
import com.qf.pojo.Book;
import com.qf.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/*
将service层配置给SpringIoc容器
service是调用dao
 */
@Service
public class BookServiceImpl implements BookService {
    /*
    使用自动装配将dao注入该属性
     */
    @Autowired
    private BookDao bookDao;//假错
    @Override
    public boolean add(Book book) {
        System.out.println(book);
        return bookDao.insertBook(book)>0;
    }

    @Override
    public List<Book> queryAll(){
        return bookDao.queryAll();
    }

    @Override
    public boolean remove(int bookId){
        return bookDao.deleteBook(bookId) > 0;
    }

    @Override
    public Book query(int bookId){
        return bookDao.query(bookId);
    }

    @Override
    public boolean update(Book book){
        return bookDao.updateBook(book)>0;
    }
}
